#!/bin/bash

function build_webrtc_audio_processing_v0
{
	cd webrtc-audio-processing-0.3.1;
	mkdir build;
	cd build;
	../configure --prefix=`pwd`/release;
	make;
	make install;
}

function clean_webrtc_audio_processing_v0
{
	cd webrtc-audio-processing-0.3.1;
	if [ -d "build" ]; then
		rm -r build;
	fi
}

function build_speexdsp
{
	cd speexdsp-1.2rc3
	mkdir build;
	cd build;
	../configure --prefix=`pwd`/release;
	make;
	make install;
}

function clean_speexdsp
{
	cd speexdsp-1.2rc3;
	if [ -d "build" ]; then
		rm -r build;
	fi
}

# conda install meson/cmake/ninja/ apt-get install pkg-config
function build_webrtc_audio_processing_v1
{
	cd webrtc-audio-processing-1.3;
	# cd subprojects/abseil-cpp-20230125.1;
	# mkdir build;
	# cd build;
	# cmake -DABSL_PROPAGATE_CXX_STD=ON -DCMAKE_INSTALL_PREFIX=`pwd`/release ..
	# cmake --build .
	# make install;
	# export PKG_CONFIG_PATH="${PWD}/release/lib/pkgconfig:${PKG_CONFIG_PATH}"
	# cd ../../..	
	mkdir build; 
	meson setup build . -Dprefix=`pwd`/build/release
	ninja -C build;
	ninja -C build install;
}

function clean_webrtc_audio_processing_v1
{
	cd webrtc-audio-processing-1.3;
	# cd subprojects/abseil-cpp-20230125.1;
	# if [ -d "build" ]; then
	# 	rm -r build;
	# fi
	# cd ../..
	if [ -d "build" ]; then
		rm -r build;
	fi
}






if [ "$1" = "build_v0" ]; then
	build_webrtc_audio_processing_v0
fi

if [ "$1" = "clean_v0" ]; then
	clean_webrtc_audio_processing_v0
fi

if [ "$1" = "build_speex" ]; then
	build_speexdsp
fi

if [ "$1" = "clean_speex" ]; then
	clean_speexdsp
fi

if [ "$1" = "build_v1" ]; then
	build_webrtc_audio_processing_v1
fi

if [ "$1" = "clean_v1" ]; then
	clean_webrtc_audio_processing_v1
fi


